<template>
  <el-row :gutter="40" class="panel-group">
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" >
        <span>
          <img alt="" src="http://localhost:9500/statics/tx.jpeg" style="width: 90px;height: 110px;">
        </span>
        <div class="card-panel-description">
          <div class="card-panel-text" style="margin-top: 15px;margin-left: 10px">
            <b style="color: #1e1e1e">{{wenhou}}</b><span style="color: red">{{userForm.nickName}} </span>
          </div>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('messages')">
        <div class="card-panel-icon-wrapper icon-message">
          <svg-icon icon-class="message" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            <b style="color: #1e1e1e">账户余额</b>
          </div>
<!--          <count-to :start-val="0" :end-val="81212" :duration="3000" class="card-panel-num" />-->
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('purchases')">
        <div class="card-panel-icon-wrapper icon-money">
          <svg-icon icon-class="money" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            <b style="color: #1e1e1e">需还款</b>
          </div>
<!--          <count-to :start-val="0" :end-val="9280" :duration="3200" class="card-panel-num" />-->
        </div>
      </div>
    </el-col>
    <!--<el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('shoppings')">
        <div class="card-panel-icon-wrapper icon-shopping">
          <svg-icon icon-class="shopping" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            订单
          </div>
          <count-to :start-val="0" :end-val="13600" :duration="3600" class="card-panel-num" />
        </div>
      </div>
    </el-col>-->
   <el-col>
     <div>
       <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick" style="width: 75%;align-items: center;">
         <el-tab-pane label="基本信息" name="first">
           <el-form :label-position="userForm" label-width="100px" :model="formLabelAlign">
             <el-form-item label="头像">
               <img alt="" :src="userForm.avatar" style="width: 90px;height: 110px;">
             </el-form-item>
             <el-form-item label="公司地址">
               <el-input v-model="userForm.companyAddress" style="width: 40%"></el-input>
             </el-form-item>
             <el-form-item label="类型">
             </el-form-item>
             <el-form-item label="法人姓名">
               <el-input readonly="readonly" v-model="userForm.faren" style="width: 40%;"></el-input>
             </el-form-item>
             <el-form-item label="身份证号">
               <el-input readonly="readonly" v-model="userForm.idCard" style="width: 40%"></el-input>
             </el-form-item>
             <el-form-item label="身份证照片">
               <img alt="" :src="userForm.idPic" style="width: 90px;height: 110px;">
             </el-form-item>
           </el-form>
         </el-tab-pane>
         <!--账户信息-->
         <el-tab-pane label="账户信息" name="second">
           <el-button type="warning" @click="dialogFormVisible=true">添加银行卡</el-button> 最多绑定<span style="color: red">5</span>张银行卡
           <p></p>
           <el-table
             :data="tableData"
             border
             style="width: 100%;">
             <el-table-column
               align="center"
               prop="date"
               label="账户类型">
             </el-table-column>
             <el-table-column
               align="center"
               prop="name"
               label="开户银行"
               width="180">
             </el-table-column>
             <el-table-column
               align="center"
               prop="address"
               label="账户名">
             </el-table-column>
             <el-table-column
               align="center"
               prop="address"
               label="银行卡号">
             </el-table-column>
             <el-table-column
               align="center"
               label="操作"
               width="150">
             </el-table-column>
           </el-table>
           <!--添加银行卡-->
           <el-dialog title="添加银行卡"  :visible.sync="dialogFormVisible" width="30%">
             <hr>
             <el-form :model="formLabelAlign"  >
               <el-form-item label="账户类型" :label-width="formLabelWidth">
                 <el-select style="width: 100%" v-model="formLabelAlign.type" placeholder="请选择账户类型">
                   <el-option value="对公账户" label="对公账户"></el-option>
                   <el-option value="对私账户" label="对私账户"></el-option>
                 </el-select>
               </el-form-item>
               <el-form-item label="开户省份" :label-width="formLabelWidth">
                 <el-select style="width: 100%" v-model="formLabelAlign.province" placeholder="请选择开户省份"></el-select>
               </el-form-item>
               <el-form-item label="开户银行" :label-width="formLabelWidth">
                 <el-select style="width: 100%" v-model="formLabelAlign.bank" placeholder="请选择开户银行"></el-select>
               </el-form-item>
               <el-form-item label="开户支行" :label-width="formLabelWidth">
                 <el-input></el-input>
               </el-form-item >
               <el-form-item label="联行行号" :label-width="formLabelWidth">
                 <el-input></el-input>
               </el-form-item>
               <el-form-item label="账户姓名" :label-width="formLabelWidth">
                 <el-input></el-input>
               </el-form-item>
               <el-form-item label="银行卡号" :label-width="formLabelWidth">
                 <el-input></el-input>
               </el-form-item>
             </el-form>
             <div slot="footer" class="dialog-footer">
               <el-button type="warning" @click="dialogFormVisible = false">保存</el-button>
             </div>
           </el-dialog>
         </el-tab-pane>
         <el-tab-pane label="账户明细" name="third">
           <el-form :model="queryAccount" >
             <el-form-item>
               <el-date-picker type="date" placeholder="请选择日期" v-model="queryAccount.condStartDate"></el-date-picker>至
               <el-date-picker type="date" placeholder="请选择日期" v-model="queryAccount.condEndDate"></el-date-picker>{{'\u3000'}}
               <el-button type="warning" @click="getAccountdetails()">查询</el-button>
             </el-form-item>
           </el-form>
           <el-table
             :data="tableData"
             border
             style="width: 100%;">
             <el-table-column
               align="center"
               :formatter="s1"
               prop="balanceType"
               label="交易类型">
             </el-table-column>
             <el-table-column
               align="center"
               prop="ywOrderNo"
               label="合同编号"
               width="180">
             </el-table-column>
             <el-table-column
               align="center"
               prop="amount"
               label="金额"
             width="120px">
             </el-table-column>
             <el-table-column
               align="center"
               prop="opItem"
               label="交易明细">
             </el-table-column>
             <el-table-column
               align="center"
               prop="statusName"
               label="交易状态">
             </el-table-column>
             <el-table-column
               align="center"
               prop="opTime"
               label="操作时间">
             </el-table-column>
           </el-table>
           <pagination
             v-show="total>0"
             :total="total"
             :page.sync="queryAccount.pageNo"
             :limit.sync="queryAccount.pageSize"
             @pagination="getAccountdetails"
           />
         </el-tab-pane>
         <el-tab-pane label="密码信息" name="fourth">
           <el-form :model="userForm" >
              <el-form-item label="登录密码"  style="margin-left: 300px">
                <el-input type="password" readonly="true" v-model="userForm.password" size="mini" style="width: 200px"></el-input>{{'\u3000'}}
                <el-button  type="warning" size="mini" @click="b=1">修改</el-button>
              </el-form-item>
             <el-form-item label="新密码"  style="margin-left: 315px" v-if="b==1">
               <el-input type="password" v-model="queryForm.endDate" size="mini" style="width: 200px"></el-input>{{'\u3000'}}
             </el-form-item>
             <el-form-item label="验证码"  style="margin-left: 315px" v-if="b==1">
               <el-input type="password" v-model="queryForm.endDate" size="mini" style="width: 200px"></el-input>{{'\u3000'}}

             </el-form-item>
             <el-form-item style="margin-left: 315px;margin-top: -20px" v-if="b==1">
               <el-button type="warning" style="margin-left: 55px" size="mini">保存</el-button>
               <el-button type="warning" style="margin-left: 85px" size="mini" @click="b=3">取消</el-button>
             </el-form-item>
             <el-form-item label="支付密码"  style="margin-left: 300px">
               <el-input type="password" readonly="true" v-model="userForm.password" size="mini" style="width: 200px"></el-input>{{'\u3000'}}
               <el-button  type="warning" size="mini" @click="a=2">修改</el-button>
             </el-form-item>
             <el-form-item label="新密码"  style="margin-left: 315px" v-if="a==2">
               <el-input type="password" v-model="queryForm.endDate" size="mini" style="width: 200px"></el-input>{{'\u3000'}}
             </el-form-item>
             <el-form-item label="验证码"  style="margin-left: 315px" v-if="a==2">
               <el-input type="password" v-model="queryForm.endDate" size="mini" style="width: 200px"></el-input><br>
               <el-button type="warning" style="margin-left: 55px" size="mini">保存</el-button>
               <el-button type="warning" style="margin-left: 85px" size="mini" @click="a=3">取消</el-button>
             </el-form-item>
           </el-form>
         </el-tab-pane>
       </el-tabs>
     </div>
   </el-col>
  </el-row>
</template>

<script>
  import {listAccount} from "@/api/system/PanelGroup";
import CountTo from 'vue-count-to'
import { getInfo } from "@/api/login";
export default {
  data(){
    return{
      activeName: 'first',
      labelPosition: 'right',
      formLabelAlign: {
        name: '',
        region: '',
        type: ''
      },
      formLabelWidth: '20%',
      dialogFormVisible:false,
      queryForm:{
        lpwd:'123',
        zpwd:'123'
      },
      a:1,
      b:0,
      wenhou:'',
      userForm:[],
      tableData:[],
      queryAccount:{
        pageNo:1,
        pageSize:10
      },
      total:0,
    }
  },
  components: {
    CountTo
  },
  created() {
    this.getWen();
    this.getUserInfo();
    this.getAccountdetails();
  },
  methods: {
    //查询账户明细
    getAccountdetails(){
      listAccount(this.queryAccount).then(res=>{
        this.tableData=res.data.list;
        this.total=res.data.total;
      })
    },
    s1(row){
      console.log(row.balanceType);
      if (row.balanceType==1){
        return this.tableData.balanceType="收入";
      }else {
        return this.tableData.balanceType="支出";
      }
    },
    getWen(){
      var date = new Date();
      var h = date.getHours();
      if (h >= 0 && h < 12) {
        this.wenhou='早上好！';
      } else if (h >= 12 && h < 18) {
        this.wenhou='下午好！';
      } else if (h >= 18 && h <= 24) {
        this.wenhou='晚上好！';
      }
    },
    getUserInfo(){
      getInfo().then(res=>{
        this.userForm=res.user
        console.log(this.userForm)
      })
    },
    handleSetLineChartData(type) {
      this.$emit('handleSetLineChartData', type)
    },
    handleClick(tab, event) {
      console.log(tab, event);

    },
  }
}
</script>

<style lang="scss" scoped>
.panel-group {
  margin-top: 18px;

  .card-panel-col {
    margin-bottom: 32px;
  }

  .card-panel {
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
    border-color: rgba(0, 0, 0, .05);

    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }

      .icon-people {
        background: #40c9c6;
      }

      .icon-message {
        background: #36a3f7;
      }

      .icon-money {
        background: #f4516c;
      }

      .icon-shopping {
        background: #34bfa3
      }
    }

    .icon-people {
      color: #40c9c6;
    }

    .icon-message {
      color: #36a3f7;
    }

    .icon-money {
      color: #f4516c;
    }

    .icon-shopping {
      color: #34bfa3
    }

    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      float: left;
      font-size: 48px;
    }

    .card-panel-description {
      float: right;
      font-weight: bold;
      margin: 26px;
      margin-left: 0px;

      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 20px;
      }
    }
  }
}

@media (max-width:550px) {
  .card-panel-description {
    display: none;
  }

  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;

    .svg-icon {
      display: block;
      margin: 14px auto !important;
      float: none !important;
    }
  }
}
</style>
